/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing_class;


import java.io.FileInputStream;
import java.util.Random;
import stendcontrol.DataProcessor;

/**
 *
 * @author Asko
 */
public class MathTest {

    static double proc[], process[];
    static double Mean, dispersion, Max, Min, sampIntrv;

    public static void main(String[] args) {

       DataProcessor dp = new DataProcessor();
        double res =  dp.vickersHardness(1.25, 0.0025, 0,51);
        System.out.println("Microhardness by VIckers ->   " + (int) res  );
        System.out.println("By Rockwool (HRA): " + dp.convertTo(1, res) );
        System.out.println("By Rockwool (HRC): " + dp.convertTo(2, res) );
        System.out.println("By Brinell : " + dp.convertTo(3, res) );
    }

    public static void fillArray(int length) {

        proc = new double[length];
        Random rand = new Random();

        for (int i = 0; i < length; i++) {

            proc[i] = rand.nextInt(100);
            System.out.println("Proc " + "[" + i + "] is " + proc[i]);
            
        }


    }

   

    public static double getMaxValue() {

        double max = process[0];

        for (int i = 0; i < process.length; i++) {

            if (max < process[i]) {
                max = process[i];
            }


        }

        Max = max;

        return max;

    }
    //Поиск минимального значения выборки

    public static double getMinValue() {

        double min = process[0];

        for (int i = 0; i < process.length; i++) {

            if (min > process[i]) {
                min = process[i];
            }


        }
        Min = min;

        return min;

    }

    /**
     * Operation
     *
     * @return double
     */
    public static double getMean() {
        double mean = 0;


        mean = getMoment(1, false);

        Mean = mean;

        return mean;
    }

    //Нахождение дисперсии
    public static double getDisp() {


        double disp = 0;

        disp = getMoment(2, true);

        dispersion = disp;


        return disp;


    }

    public static double getMoment(int order, boolean central) {

        double moment = 0, sum = 0, div = 0;

        if (central) {


            for (int i = 0; i < process.length; i++) {


                div += Math.pow((process[i] - Mean), order);

            }
            System.out.println("Div is " + div);
            moment = 1.0 / (process.length - 1) * div;



        } else {

            for (int i = 0; i < process.length; i++) {
                sum += Math.pow(process[i], order);
            }

            moment = sum * Math.pow(process.length, -1);

        }



        return moment;
    }
}
